Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1012 Bytes

File metadata and controls

34 lines (25 loc) · 1012 Bytes

Mock'Em All

Definition:

  • When a test overuse all kinds of test double, even when it is not really the best option

Code Example:

@Test
public void shouldAddTimeZoneToModelAndView() {
  //given
  Context context = mock(Context.class);
  ModelAndView modelAndView = mock(ModelAndView.class);
  given(context.getTimezone()).willReturn("timezone X");
  //when
  new UserDataInterceptor(context)
  .postHandle(null, null, null, modelAndView);
  //then
  verify(modelAndView).addObject("timezone", "timezone X");
}

References:

Quality attributes